<template>
  <div class="sponsor-box">
    <div v-if="list && list.list.length>0">
      <el-table :data="list.list" style="width: 100%">
        <el-table-column
          label="约定支付时间"
          width="120">
          <template slot-scope="scope">
            <p>{{scope.row.payTime | FormatDate('yyyy-MM-dd')}}</p>
            <!--<p>{{scope.row.lastTime}}</p>-->
            <p v-if="scope.row.goodsStatus != 2" :class="scope.row.payTime<toDay?'last-style':'next-style'">{{scope.row.payTime | lastDate}}</p><br />
            <!--<p class="last-style"></p>-->
            <!--<p class="last-style">{{scope.row.lastTime === '到期' ? '到期' : '未知'}}</p>-->
          </template>
        </el-table-column>
        <el-table-column
          label="赞助单位/权益名称"
          width="200">
          <template slot-scope="scope">
            <p>{{scope.row.nickName}}/{{scope.row.rightsName}}</p>
            <p class="name-style" v-if="scope.row.sponsorType === 1">第{{scope.row.goodsNumber}}期</p>
          </template>
        </el-table-column>
        <el-table-column
          label="价值"
          width="110">
          <template slot-scope="scope">
            {{scope.row.investmentAmount | formatMoney}}
          </template>
        </el-table-column>
        <el-table-column
          label="赞助类型"
          width="100">
          <template slot-scope="scope">
            <p>{{scope.row.sponsorType === 1 ? '招商金额' : '实物总价'}}</p>
          </template>
        </el-table-column>
        <el-table-column
          prop="confirmStatus"
          label="支付状态"
          width="100">
          <template slot-scope="scope">
            <!--<p>{{scope.row.confirmStatus === 0 ? '未支付' : '已支付'}}</p>-->
            <p v-if="scope.row.sponsorType === 1">{{scope.row.goodsStatus | payFormat}}</p>
            <p v-else>{{scope.row.goodsStatus === 2 ? '支付成功' : '线下支付'}}</p>
          </template>
        </el-table-column>
        <el-table-column
          label="操作">
          <template slot-scope="scope">
            <!--{{scope.row.remindTime | FormatDate('yyyy-MM-dd HH:mm:ss')}}
            {{toDay | FormatDate('yyyy-MM-dd HH:mm:ss')}}-->
            <el-button
              type="primary"
              v-if="scope.row.confirmStatus === 0"
              size="mini"
              @click="confirmPay(scope.row)">确认收款</el-button>
              <!--后期做<el-tooltip class="item" effect="dark" content="48小时内只能提醒一次" placement="top">
                <template>
                  <el-button            
                  type="default"
                  v-if="scope.row.confirmStatus === 0"
                  @click="toDay-scope.row.remindTime>48*3600000?remindPayment(scope.row):''"
                  :class="toDay-scope.row.remindTime<48*3600000?'is-disabled':''">提醒对方</el-button>
                </template>
              </el-tooltip>-->
            <p v-if="scope.row.confirmStatus === 1">已确认收款</p>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        v-bind="getPaginationProps(list)"
        @current-change="handleCurrentChange"
        @size-change="handleSizeChange"
        >
      </el-pagination>
    </div>
    <e-placeholder v-else text="暂时没有赞助哦" src="/static/images/no_match.png"></e-placeholder>
  </div>
</template>
<script>
  import api from 'api/merchants'
  import { mapGetters } from 'vuex'
  import { pagingList } from 'utils/mixins'
  export default{
    mixins: [pagingList],
    computed: {
      ...mapGetters({
        list: 'sponsorship_merchants_list'
      })
    },
    components: {
      mapGetters
    },
    data () {
      return {
        query: this.getQuery(),
        toDay: new Date()
      }
    },
    methods: {
      onSubmit () {
        console.log('submit!')
      },
      fetch (query) { // 初始化获取数据， 分页
        // query.merId = 74
        query.merId = this.$route.params.id
        this.$store.dispatch('sponsorship_merchants_list', query)
      },
      confirmPay (row) { // 确认收款
        this.$confirm('确认该订单已成功收款？',
          '提示',
          {type: 'warning'}
        ).then(() => {
          this.$store.dispatch('pay_merchants_changestate', row)
        }).catch(() => {
        })
      },
      remindPayment (row) { // 提醒支付
        api.remind_payment({
          id: row.id
        }, {context: this, successMsg: 'none'}).then(res => {
          row.remindTime = new Date()
        })
      }
    }
  }
</script>
<style lang="scss">
  .sponsor-box{
    margin:35px 60px;
    .el-table thead th{
      background: #f5f5f5;
      font-weight: 500;
    }
    .el-table tbody td{
      height:120px;
    }
    .name-style{
      font-weight: 700;
    }
    .last-style{
      display: inline-block;
      padding:0px 4px;
      background: red;
      color: white;
      font-size: 12px;
    }
    .next-style{
      color:#00bb90;
    }
  }
</style>
